package com.complex.spring.advance.service.messagesource;

import java.text.MessageFormat;
import java.util.Date;
/**
 * MessageFormat
 * 提供了以与语言无关方式生成连接消息的方式
 * 获取一组对象，格式化这些对象，然后将格式化后的字符串插入到模式中的适当位置。 
 * @author gao
 *
 */
public class TestMessageFormat {
	public static void main(String[] args) {
		/**使用arguments来格式化输入的字符串*/
		int planet = 7;
		String event = "a disturbance in the Force";

		String result = MessageFormat
				.format(
						"At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.",
						planet, new Date(), event);
		System.out.println(result);

		System.out.println(MessageFormat.format("Today is {0}", new Date()));
		System.out.println(MessageFormat.format(
				"My age is {0},I was borm at {1}.", 26, 1979));
	}
}
